import { IsArray, IsEnum, IsNotEmpty, IsNumber, MaxLength } from 'class-validator'
import i18n, { i18nMessage } from '@/i18n'
import { DomainModel } from '@apps/meta/domain/model'
import { ApiProperty } from '@nestjs/swagger'

export class MetaResourceModelBatchSaveDto {
  @ApiProperty({
    description: i18n.t('app-meta.dto.meta-resource-model-batch-save.12151145-0'),
    enum: DomainModel.ApiPropertyEnum.MetaResourceModelType,
  })
  @IsNotEmpty()
  @IsEnum(DomainModel.MetaResourceModelType)
  type: DomainModel.MetaResourceModelType

  @ApiProperty({ description: i18n.t('app-meta.dto.meta-resource-model-batch-save.12151145-1'), type: Number })
  @IsNotEmpty()
  @IsNumber()
  relativeId: number

  @ApiProperty({
    description: i18n.t('app-meta.dto.meta-resource-model-batch-save.12151145-2'),
    enum: DomainModel.ApiPropertyEnum.MetaResourceRelativeType,
  })
  @IsNotEmpty()
  @IsEnum(DomainModel.MetaResourceRelativeType)
  relativeType: DomainModel.MetaResourceRelativeType

  @ApiProperty({ description: i18n.t('app-meta.dto.meta-resource-model-batch-save.12151145-3') })
  @IsArray({ each: true })
  items: MetaResourceModelBatchSaveItemDto[]
}

export class MetaResourceModelBatchSaveItemDto {
  @ApiProperty({ description: i18n.t('app-meta.dto.meta-resource-model-batch-save.12151145-4'), type: String })
  @IsNotEmpty()
  @MaxLength(64, { message: i18nMessage() })
  name: string

  @ApiProperty({ description: i18n.t('app-meta.dto.meta-resource-model-batch-save.12151145-5'), type: String })
  @IsNotEmpty()
  @MaxLength(64, { message: i18nMessage() })
  label: string

  @ApiProperty({
    description: i18n.t('app-meta.dto.meta-resource-model-batch-save.12151145-6'),
    enum: DomainModel.ApiPropertyEnum.MetaResourceModelDataType,
  })
  @IsNotEmpty()
  @IsEnum(DomainModel.MetaResourceModelDataType)
  dataType: DomainModel.MetaResourceModelDataType
}
